package at.studentinformation;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class LoginActivity extends Activity {	
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.login);
		
		final EditText username = (EditText)findViewById(R.id.userName);
		final EditText password = (EditText)findViewById(R.id.passWord);
		final Button loginBtn = (Button)findViewById(R.id.loginBtn);			
		
		loginBtn.setOnClickListener(new OnClickListener(){
			public void onClick(View v) {
				// TODO Auto-generated method stub
				boolean loginFlag = ServiceConnector.Login(username.getText().toString(), password.getText().toString());
				if(loginFlag)
				{
					Common.userName = username.getText().toString();
					Common.passWord = password.getText().toString();
					Common.isLogin = true;
					
					Intent loginIntent = new Intent(LoginActivity.this, StudentInformationActivity.class);			
			    	startActivity(loginIntent);
			    	
			    	finish();
				}
			}		
		});		
	}
}